package cn.wqk.rrtf.service;

import cn.wqk.rrtf.mapper.UserMapper;
import cn.wqk.rrtf.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(String username) {
        User user = new User();
        user.setUsername(username);
        List<User> userList = userMapper.selectUserByCondition(user);
        return userList.get(0);
    }

    @Override
    public User selectUserByUsername(String username) {
        return userMapper.selectUserByUsername(username);
    }

    @Override
    public List<User> selectUser(User user) {
        List<User> userList=userMapper.selectUserByCondition(user);
        return userList;
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUserByManagerId(user);
    }

    @Override
    public int deleteUser(@Param("userId") Integer userId) {
        return userMapper.deleteUserByManagerId(userId);
    }
}
